<?php
header('Content-Type:text/html; Charset=UTF-8');
require 'lib/checker.php';

@$id = $_REQUEST['id'];

$title = '编辑菜品错误提示';
$jumpUrl = 'dishList.php';

if(empty($id)){
	$message = '获取菜品信息出错';
	include 'lib/message.php';
	die;
}

require 'lib/db.php';

@$entry = dbSelect('select id,name,imgUrl,price,type_id from entry where id=:id',array('id'=>$id));
require 'lib/header.php';
?>
		<form class="col-md-2 col-sm-6">
            <form class="navbar-form navbar-left form-inline" role="search">
                <div class="col-xs-12">
                    <div class="form-group">
                        <div class="input-group">
                            <a href="dishAdd.php" class="btn btn-primary btn-lg btn-block">添加菜品</a>
                            <a href="dishList.php" class="btn btn-primary btn-lg btn-block">菜品列表</a>
                            <a href="main.php" class="btn btn-primary btn-lg btn-block">返回首页</a>
                        </div>
                    </div>
                </div>
            </form>
            <div class="col-xs-12 col-sm-8">
                <div class="row">
                    <div class="col-md-6 col-xs-12">
                        <div class="panel panel-primary">
                            <div class="panel-heading">
                                <div class="panel-title">
                                    <span class="glyphicon glyphicon-edit"></span> 编辑菜品<span class="col-md-offset-8"></span>
                                </div>
                            </div>
                            <form action="updateDish.php" method="post" enctype="multipart/form-data" class="form-horizontal">
	                            <input type="hidden" name="id" value="<?php echo $entry['id'];?>"/>
	                            <div class="panel-body">
	                                <div class="form-horizontal">
									  <div class="form-group">
                                         <label class="col-xs-4 control-label">菜名：</label>
                                         <div class="col-xs-7">
                                              <input class="form-control" value="<?php echo $entry['name']; ?>" name="newName" />
                                              <input type="hidden" value="<?php echo $entry['name']; ?>" class="form-control" name="oldName" />
                                         </div>
                                      </div>
                                      <div class="form-group">
				                          <label class="control-label col-xs-4">单价：</label>
				                          <div class="col-xs-7">n
				                              <input required="required" name="newprice" value="<?php echo $entry['price']; ?>" type="number" min="1" class="form-control" placeholder="单价">
				                              <input type="hidden" required="required" name="oldprice" value="<?php echo $entry['price']; ?>" type="number" min="1" class="form-control" placeholder="单价">
				                          </div>
				                      </div>
				                      <div class="form-group">
										<label class="col-xs-4 control-label" for="typeInput">类型：</label>
										<div class="col-xs-7">
											<select id="typeInput" name="type" class="form-control">
												<option value="<?php echo $entry['type']; ?>"><?php echo $entry['type']; ?></option>
													<option value="烧菜">烧菜</option>
													<option value="烧烤">烧烤</option>
													<option value="点心">点心</option>
											</select>
										</div>
	                                  </div>
	                                  <div class="form-group">
	                                	<label class="control-label col-xs-4">照片：</label>
											<div class="col-xs-7 ">
											<label class="sr-only" for="1113"></label>
										    <div class="input-group">
										      <input name="newimg" type="file" class="filestyle" data-buttonBefore="true" data-buttonText="选择文件" /><br />
										      <input type="hidden" name="oldimg" type="file" class="filestyle" data-buttonBefore="true" data-buttonText="选择文件" /><br />
										    </div>
											</div>
	                                  </div>
									</div>
	                            </div>
	                            <div class="panel-footer">
					      			<button type="submit" class="btn btn-primary btn-lg btn-block">修改菜品</button>
					      		</div>
				      		</form>
                        </div>
                    </div>
                </div>
            </div>
        </form>
   </body>
</html>
